home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #14 / Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO / os2 / mlrxshl.zip / PROFILE1.SHL < prev    next >
Text File  |  1995-10-06  |  12KB  |  200 lines

  1. /* profile.shl - Emacs bindings                                950804 */
  2.  
  3.  
  4. /* This profile file demonstrates typical profile usage:              */
  5. /*                                                                    */
  6. /*       - simulating another product, by defining new keys           */
  7. /*         [The emacs-like C-A, C-E, C-B, C-F, C-N keys]              */
  8. /*                                                                    */
  9. /*       - Improving/tailoring existing commands, adding shortcuts    */
  10. /*         [The auto-close '(', the insert-date key (F8), and S-F7,   */
  11. /*         which displays all possible filenames.]                    */
  12. /*                                                                    */
  13. /*       - Adding new functions                                       */
  14. /*         [The persistent command history, F2 (save), F5 (load) and  */
  15. /*         F7 (name).]                                                */
  16. /*                                                                    */
  17. /*       - National Language Support                                  */
  18. /*         [on-line messages in French.]                              */
  19.  
  20.  
  21. /* In a profile file, you can use any REXX instruction, but, due to   */
  22. /* the current implementation, it must fit in one line.               */
  23. /*                                                                    */
  24. /* That is, you can use:                                              */
  25. /*                                                                    */
  26. /*     if foo = 'XYZZY' then say 'Nothing happens'; else  x = x + 1   */
  27. /*                                                                    */
  28. /* But you can't use:                                                 */
  29. /*                                                                    */
  30. /*     if foo = 'XYZZY' then                                          */
  31. /*        say 'Twice as much happens'                                 */
  32. /*     else                                                           */
  33. /*        x = x + 1                                                   */
  34. /*                                                                    */
  35. /* Alternatively, you can use the comma as a line continuation marker */
  36. /*                                                                    */
  37. /*     foo = 'Hello',                                                 */
  38. /*           'world'                                                  */
  39. /*                                                                    */
  40. /* Another important difference with standard REXX scripts is that    */
  41. /* you cannot call CmdShl commands in a REXX structure using the      */
  42. /* standard way.  You have to use the eval function.  That is,        */
  43. /*                                                                    */
  44. /*     if answer = 'YES' then                                         */
  45. /*        'DEFINE F12 OSNOWAIT shutdown'                              */
  46. /*     else                                                           */
  47. /*        'DEFINE F12 TEXT shutdown'                                  */
  48. /*                                                                    */
  49. /* does not work.  You have to use:                                   */
  50. /*                                                                    */
  51. /*     if answer = 'YES' then                                         */
  52. /*        call eval 'DEFINE F12 OSNOWAIT shutdown'                    */
  53. /*     else                                                           */
  54. /*        call eval 'DEFINE F12 TEXT shutdown'                        */
  55. /*                                                                    */
  56. /* [But it works just fine outside of a structure.]                   */
  57.  
  58.  
  59. /* Note: when a command name is in mixed case, like DEFine below, it  */
  60. /*       means that you can use DEF, DEFI, DEFIN or DEFINE.           */
  61.  
  62. /*                                                                    */
  63. /* There's currently only one "pseudo" command, DEFine, which is most */
  64. /* useful in profile file. Its syntax is as follows:                  */
  65. /*                                                                    */
  66. /*     DEFine key value                                               */
  67. /*                                                                    */
  68. /* Key is a user-defined key or a predefined one:                     */
  69. /*                                                                    */
  70. /*     A-F10, BKSP, CURD, CURL, CURR, CURU, C-CURL, C-CURR, C-END,    */
  71. /*     C-HOME, C-PGDN, C-PGUP, DEL, END, ENTER, ESC, F1, F2, F3, F4,  */
  72. /*     F5, F6, F7, F8, F9, F10, F11, F12, HOME, INS, PGDN, PGUP,      */
  73. /*     SPACE, S-TAB, TAB                                              */
  74. /*                                                                    */
  75. /*     [Shifted keys have a "S-" prefix, control keys have a "C-"     */
  76. /*      prefix and Alt keys have a "A-" prefix.]                      */
  77. /*                                                                    */
  78. /* and value is an internal key name or TEXT nnn or OSNowait nnn:     */
  79. /*                                                                    */
  80. /*     backsp, cdown, cleft, cright, ctrlend, ctrlhome, ctrlleft,     */
  81. /*     ctrlright, cup, del, end, enter, esc, f1, home, ins, tab,      */
  82. /*     space                                                          */
  83. /*                                                                    */
  84. /*     TEXT nnn simulates the keyboard entry of nnn                   */
  85. /*                                                                    */
  86. /*     OSNowait cmd executes cmd (via the CmdShl interpretor)         */
  87. /*                                                                    */
  88. /* All other "pseudo" commands are executed via CmdShl's interpretor. */
  89.  
  90. /* [In fact, the DEFine command could have been implemented as an     */
  91. /*  alias:                                                            */
  92. /*                                                                    */
  93. /*     ALIAS DEFINE=RX _args="%*";                                    */
  94. /*                     parse value _args with key rest;               */
  95. /*                     if length(key) > 1 then                        */
  96. /*                        key = value(translate(key,'_','-'));        */
  97. /*                     if rest \= '' then                             */
  98. /*                        call value "key._"c2x(key), rest;           */
  99. /*                     else interpret "drop key._"c2x(key)'           */
  100. /*                                                                    */
  101. /*  It's functionnaly equivalent.]                                    */
  102.  
  103. /* user-defined key name - note the usage of "_" in place of "-" in   */
  104. /*                         the key name (you can't use "-" in a REXX  */
  105. /*                         variable name).                            */
  106. /*                                                                    */
  107. /*                         The value of a key name is the hexadecimal */
  108. /*                         value returned by the getKey function when */
  109. /*                         pressing it (you can use the following     */
  110. /*                         CmdShl command to find it) :               */
  111. /*                                                                    */
  112. /*                         RX call getkey; say "'"substr(ckey,2)"'x"  */
  113.  
  114. /* Note: by default, variables are hidden when inside a getLine call. */
  115. /*       If you want to expose some of them, add them to the global   */
  116. /*       variable -- global = global "newname1 newname2"              */
  117. /*                                                                    */
  118. /*       So, each time you use one of your variable in the right hand */
  119. /*       side of a DEFine command, you have to expose it.             */
  120.  
  121.  
  122. C_A = '01'x; C_B = '02'x; C_E = '05'x; C_F = '06'x; C_N = '0E'x;
  123. S_F7 = '005A'x
  124.  
  125.  
  126. /* defining key value - a shifted key can use "-" or "_" in its name  */
  127. 'DEFINE C-A home'
  128. 'DEFINE C-B left'
  129. 'DEFINE C-F right'
  130. 'DEFINE C-E end'
  131. 'DEFINE C-N cdown'
  132.  
  133. 'DEFINE F3 OSNOWAIT EXIT'
  134.  
  135.  
  136. /* you can even do complex things:                                    */
  137. 'DEFINE (  OSNOWAIT RX line = insert("()",line,currOfs); currOfs = currOfs+1'
  138.  
  139. 'DEFINE F8 OSNOWAIT RX line = insert(date(),line,currOfs); currOfs = currOfs+length(date())'
  140.  
  141. 'DEFINE S-F7 osn rx if currTab \= 0 then do; say; do i = 1 to tree.0; say tree.i; end; call charout, print(); oline=""; parse value SysCurPos() with origRow origCol .; key="tab"; end'
  142.  
  143.  
  144. /* we can even add a new feature: loading/saving commands history     */
  145.  
  146. /* first, we define a file name (and make it public, F7 requires it): */
  147. history = 'd:\tmp\history.shl'; global = global 'history'
  148.  
  149. /* then, an alias, LOADHIST, which loads the commands history         */
  150. 'ALIAS LOADHIST=RX drop prevLine.; i = 0; do while lines(history); i = i+1; prevLine.i = linein(history); end; prevLine.0 = i; call stream history, "c", "close"'
  151.  
  152. /* now, we define three function keys, F2 (save), F5 (load/refresh)   */
  153. /* and F7 (name)                                                      */
  154. 'DEFINE F2 OSNOWAIT RX "@del /f" history; do i = 1 to prevLine.0; call lineout history, prevLine.i; end; call stream history, "c", "close"'
  155. 'DEFINE F5 OSNOWAIT LOADHIST'
  156. 'DEFINE F7 OSNOWAIT RX call charout ,"1b"x"[s"||"1b"x"[0;0H"||"1b"x"[1;37;42m"||"1b"x"[KNew history name: "; history=getLine(history); call charout ,"1b"x"[0;0H"||"1b"x"[1;37;44m"||"1b"x"[K"helpstring"1b"x"[0m"||"1b"x"[u"'
  157.  
  158. /* finally, we load the default history                               */
  159. 'LOADHIST'
  160.  
  161.  
  162. /* Here, we redefine help messages in French...                       */
  163.  
  164. defHelp = "Utilisez la command DEFINE pour (re)définir le rôle des touches"nl||,
  165.           "du clavier"nl||nl||,
  166.           "SYNTAXE:    DEF touche [valeur]"nl||,
  167.           "         DEFINE touche [valeur]"nl||nl||,
  168.           "          touche  Spécifie le nom de la touche à définir"nl||,
  169.           "          value   Valeur affectée à la touche. Ce peut être une"nl||,
  170.           "                  commande interne, OSNowait xxx ou TEXT yyy."nl||nl||,
  171.           "Exemples:"nl||,
  172.           "          DEF F12 TEXT dir /w"nl||,
  173.           "       DEFINE F3  OSNOWAIT exit"nl||,
  174.           "          DEF F12"
  175. aliasHelp = "Utilisez la commande ALIAS pour afficher, définir ou"nl||,
  176.             "supprimer un alias"nl||nl||,
  177.             "SYNTAXE: ALIAS [LIST|alias=[chaîne]|@fichier]"nl||nl||,
  178.             "          LIST     Affiche la liste des alias en cours."nl||,
  179.             "          alias    Spécifie le nom de l'alias."nl||,
  180.             "          chaîne   Valeur alphanumérique affectée à l'alias."nl||,
  181.             "          fichier  Nom d'un fichier contenant un ensemble de"nl||,
  182.             "                   définitions d'alias."nl||nl||,
  183.             "Dans la définition d'un alias, %* correspond aux paramètres"nl||,
  184.             "passés sur la ligne de commande."
  185. cmdHelp = "Utilisez la commande CMDSHL pour augmenter les capacités de"nl||,
  186.           "votre interprèteur de commande"nl||nl||,
  187.           "SYNTAXE: CMDSHL [/I|/O] [/P profile] [/C cmd|/K cmd]"nl||nl||,
  188.           "          /I    Sélecte le mode Insertion par défaut."nl||,
  189.           "          /O    Sélecte le mode surfrappe par défaut."nl||,
  190.           "          /P    Utilise le fichier profile spécifié."nl||,
  191.           "          /C    Exécute la commande cmd et met fin à l'exécution"nl||,
  192.           "                de CMDSHL."nl||,
  193.           "          /K    Exécute la commande cmd sans mettre fin à l'exécution"nl||,
  194.           "                de CMDSHL."nl||nl||,
  195.           "Par défaut, le mode Insertion est actif et le fichier PROFILE.SHL"nl||,
  196.           "est utilisé comme profile s'il existe sur le chemin spécifié par"nl||,
  197.           "la variable d'environnement DPATH."
  198. cdHelp = "Tapez CD -        Pour retourner au répertoire précédent."
  199.  
  200.